<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>六西格玛知识管理</title>
<link href="<?php echo $this->baseUrl ?>/public/style/style.css" rel="stylesheet" type="text/css">
<link href="<?php echo $this->baseUrl ?>/public/style/jquery.treeview.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->baseUrl ?>/public/style/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->baseUrl ?>/public/style/thickbox.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo $this->baseUrl;?>/public/scripts/jquery.js"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl ?>/public/scripts/jquery.treeview.js"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl ?>/public/scripts/jquery-ui.js"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl ?>/public/scripts/thickbox-compressed.js"></script>
<script type="text/javascript">
$(function() {
	$("#tree").treeview({
		collapsed: false,
		animated: "medium",
		control: "#sidetreecontrol"
	});
})
</script>
</head>

<body>
<!--头部-->
<?php echo $this->partial('common/header.html', array('template'=>$this->template, 'baseUrl'=>$this->baseUrl)) ?>

<!--主体-->
<div class="main-box" id="mainBox">
    <div class="third-menu">
        <?php echo $this->partial('common/operation.html', array('template'=>$this->template, 'baseUrl'=>$this->baseUrl)) ?>
        <div class="menu-title"><span class="icon"></span>标签树管理页</div>
    </div>
    
    <div class="mod-tree">
        <div class="tree-list">
            <div class="t"><div class="r"></div></div>
            <div class="m">
            	<?php 
                	$_GET['tree_id'] = isset($_GET['tree_id'])?$_GET['tree_id']:1; 
                ?>
                <div class="container" id="container">
                	<?php if($this->alltree): ?>
                	<?php foreach ($this->alltree as $key => $val): ?> 
                    <a class="label <?php if(isset($_GET['tree_id'])&&$val['tree_id']==$_GET['tree_id'])echo 'on'; ?>" href="?tree_id=<?php echo $val['tree_id']; ?>"><?php echo $val['name']; ?></a>
                    <?php endforeach; ?>
                    <?php endif; ?>
                </div>
            </div>
            <div class="b"><div class="r"></div></div>
        </div>
        <div class="tree-right">
            <div class="tree-box">
                <div class="t"><div class="r"></div></div>
                <div class="m"><div class="container">
                	<div class="key-title">
                        <span id="tree_title">标签树结构信息</span>
                    </div>
                    <?php
                    $arrTagIds = array();
                    foreach($this->tagtree as $key=>$row){
                    	$arrTagIds[] = $row['tag_id'];
                    }
                    function recursion($arr, $bolFirst = true){
                    	echo $bolFirst?"<ul id='tree' style='margin:10px 0 0 15px'>":"<ul>";
                    	foreach($arr as $row){
                        	if(is_array($row[0])){
                            	recursion($row, false);
                                echo "</li>";
                            }else{
                            	if($row['tag_id']==$_GET['tag_id']){
                                	echo "<li><a id='current_tag' href='?tree_id=".$_GET['tree_id']."&tag_id=".$row['tag_id']."&id=".$row['id']."'>".$row['name']."</a>&nbsp;&nbsp;<a href='/tree/deletetagtree?tree_id=".$_GET['tree_id']."&tag_id=".$row['tag_id']."&id=".$row['id']."'>删除</a>";
                                }else{
                                	echo "<li><a href='?tree_id=".$_GET['tree_id']."&tag_id=".$row['tag_id']."&id=".$row['id']."'>".$row['name']."</a>&nbsp;&nbsp;<a href='/tree/deletetagtree?tree_id=".$_GET['tree_id']."&tag_id=".$row['tag_id']."&id=".$row['id']."'>删除</a>";
                                }
                            }
                        }
                        echo "</ul>";
                    }
                    if(!empty($this->tags)){
                    	recursion($this->tags, true);
                    }
                    ?>
                </div></div>
                <div class="b"><div class="r"></div></div>
            </div>
            <div class="tree-keys">
                <div class="t"><div class="r"></div></div>
                <div class="m"><div class="container">
                    <div class="key-title">
                        <span><span id="tag_name" style="margin-left:0; color:#C00; font-weight:600"></span>可选标签</span>
                    </div>
                    <div class="key-form">
                    	<form name="form1" action="<?php echo $this->baseUrl ?>/tree/manage" method="get">
                            <input type="text" class="search-input" name="search" />
                            <input type="hidden" name="tree_id" value="<?php echo $_GET['tree_id']; ?>" />
                            <input type="hidden" name="tag_id" value="<?php echo $_GET['tag_id']; ?>" />
                            <input type="submit" class="search-submit" value="" />
                    	</form>
                    </div>
                    <div class="key-keys" id="key-keys">
                    	<?php foreach ($this->alltag as $key => $val): ?>
                        <?php if (!in_array($val['tag_id'],$arrTagIds)): ?>
                        <div class="item"><a href='#TB_inline?keepThis=true&height=64&width=360&inlineId=hiddenModalContent' class='thickbox tag_msg'><?php echo $val['name']; ?></a><span style="display:none"><?php echo $val['tag_id']; ?></span></div>
                        <?php endif; ?>
                        <?php endforeach; ?>
                    </div>
                </div></div>
                <div class="b"><div class="r"></div></div>
            </div>
            <div class="tree-desc" id="tree-desc">
                <div class="t"><div class="r"></div></div>
                <div class="m"><div class="container">
                    <div class="desc-title" id="desc-title"><?php echo $this->tag[0]['name']; ?></div>
                    <div class="desc-info">
                        <span class="keys">关键字：<?php echo $this->tag[0]['key_word']; ?></span>
                        <span class="time">创建时间：<?php echo date('Y-m-d',$this->tag[0]['create_time']); ?></span>
                    </div>
                    <div class="desc-detail">
                    <form action="<?php echo $this->baseUrl ?>/tree/file" method="post" enctype="multipart/form-data" name="file_up">
                    	添加标签挂载文档：
                    	<input type="file" class="input-text" name="file_upload" />
                        <input type="hidden" name="tag_tree_id" value="<?php echo $_GET['id']; ?>" />
                        描述：<input type="text" name="summary" />
                        <input type="hidden" name="tree_id" value="<?php echo $_GET['tree_id']; ?>" />
                        <input type="submit" class="button" value="提交" />
                    </form>
                    </div>
                    <!--div class="desc-detail">
                        <div class="detail-left">相关项目：</div>
                        <div class="detail-right">
                            <div class="detail-item">飞机制造项目</div>
                            <div class="detail-item">飞机制造项目</div>
                            <div class="detail-item">飞机制造项目</div>
                            <div class="detail-item">飞机制造项目</div>
                            <div class="detail-item">飞机制造项目</div>
                        </div>
                    </div-->
                </div></div>
                <div class="b"><div class="r"></div></div>
            </div>
        </div>
	</div>
</div>
<div id="hiddenModalContent" style="display:none">
<div class="mod-popSelect" style="width:350px; margin:auto;">
	<form action="<?php echo $this->baseUrl ?>/tree/addtagtree" name="form1" method="post">
    	<?php if (isset($_GET['tag_id'])): ?>
        <div class="select-list" style="height:20px; text-align:center; line-height:20px">
             将<span id="child_tag"></span>设置为<span id="parent_tag"></span>的子标签
        </div>
        <?php else: ?>
        <div class="select-list" style="height:20px; text-align:center; line-height:20px">
             将<span id="child_tag"></span>设置为一级父标签
        </div>
        <?php endif; ?>
        <input type="hidden" name="tree_id" id="hidden_tree_id" value="<?php echo !empty($_GET['tree_id'])?$_GET['tree_id']:0; ?>" />
        <input type="hidden" name="tag_id" id="hidden_tag_id" value="" />
        <input type="hidden" name="pid" id="hidden_pid" value="<?php echo !empty($_GET['tag_id'])?$_GET['tag_id']:0; ?>" />
        <div class="select-submit" style="text-align:center"><input type="submit" class="select-btn" value="确认选择" id="choose_case" style="margin-left:0" />
        </div>
    </form>
</div>
</div>
<script>
$(document).ready(function(){
	$("#container a").hover(
		function(){
			$(this).addClass('hover');
		},
		function(){
			$(this).removeClass('hover');
		}
	);
	$("#show_tag_all").click(function(){
		$("#tag_name").text('所有');
		return false;
	});
	$(".tag_msg").click(function(){
		var child_tag = $(this).text();
		var parent_tag = $("#current_tag").text();
		var tag_id = $(this).siblings("span").text();
		$("#child_tag").text(child_tag);
		$("#parent_tag").text(parent_tag);
		$("#hidden_tag_id").val(tag_id);
	});
});
</script>
<!--底部-->
<?php echo $this->partial('common/footer.html') ?>
</body>
</html>
